<!--
 * @Author: wangjh wangjiahui0710@163.com
 * @Date: 2024-06-18 10:06:27
 * @LastEditors: wangjh wangjiahui0710@163.com
 * @LastEditTime: 2024-07-17 17:45:37
 * @FilePath: \cip-admin\src\pages\park\dual-prevention\inspection-plan\components\filter.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script lang="ts" setup>
import { injectState } from "../state";
import { CHECK_PLAN_OPTIONS } from "@/config/enum-map";

defineOptions({ name: "Filters" });

const {
	filter,
	page: { isLoading },
} = injectState()!;

const initial = { ...toRaw(filter.value) };
const data = ref({ ...initial });

const search = () => {
	filter.value = { ...toRaw(data.value) };
};

const reset = () => {
	data.value = { ...initial };
};
</script>

<template>
	<el-form class="filter-form" inline :model="data" :disabled="isLoading">
		<el-form-item label="检查类型筛选" prop="检查状态类型筛选">
			<el-select-v2
				v-model="data.type"
				clearable
				class="w-240px!"
				:options="CHECK_PLAN_OPTIONS"
				placeholder="请选择检查类型"
			/>
		</el-form-item>
		<el-form-item label="检查周期" prop="检查周期">
			<el-date-picker
				v-model="data.checkStartDate"
				clearable
				type="date"
				class="w-240px!"
				placeholder="开始日期"
				value-format="YYYY-MM-DD"
			/>
		</el-form-item>
		<el-form-item label="—" prop="—">
			<el-date-picker
				v-model="data.checkEndDate"
				clearable
				type="date"
				class="w-240px!"
				placeholder="结束日期"
				value-format="YYYY-MM-DD"
			/>
		</el-form-item>
		<el-form-item>
			<el-divider direction="vertical" h="32px!" m="r-22px!" />
			<el-button type="primary" :loading="isLoading" @click="search">
				<template #icon>
					<el-icon class="i-custom:search" />
				</template>
				查询
			</el-button>
			<el-button @click="reset">
				<template #icon>
					<el-icon class="i-custom:reset" />
				</template>
				重置
			</el-button>
		</el-form-item>
	</el-form>
</template>
